function MySet() {
  this.items = {};

  MySet.prototype.add = function (val) {
    if (this.has(val)) return false;

    this.items[val] = val;
  };
  MySet.prototype.has = function (val) {
    return this.items.hasOwnProperty(val);
  };
  MySet.prototype.remove = function (val) {
    if (!this.has(val)) return false;
    delete this.items[val];
    return true;
  };

  MySet.prototype.clear = function () {
    this.items = {};
  };
  MySet.prototype.size = function () {
    return Object.keys(this.items).length;
  };
  MySet.prototype.values = function () {
    return Object.keys(this.items);
  };
}

const set = new Set([1, 2, 3]);
console.log([...set]);

function doAwayByArrMethod(arr) {
  return arr.filter((item, idx) => arr.indexOf(item) == idx);
}
let o = { 1: 1 };
function doAwayBySet(arr) {
  const set = new Set(arr);
  return [...set];
}
console.log(doAwayByArrMethod([1, 2, o, o, +0, -0,NaN,NaN]));
console.log(doAwayBySet([1, 2, o, o,+0,-0,NaN,NaN]));
